# @shuaige : 陈世玉
# @name :01-get请求encode方法.py
# @time :2024/9/19 下午10:30
import urllib.request
import urllib.parse
import json
data={
    'wd':'周杰伦',
    'dender':"男"
}
data=urllib.parse.urlencode(data)# 将字典转化为url编码
url="http://www.baidu.com/s?"+data
headers={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
}
request=urllib.request.Request(url=url,headers=headers)# 创建请求对象
response=urllib.request.urlopen(request)
html=response.read().decode("utf-8")# 解码 decode进行解码
print(html)


